package com.proton.carepatchtemp.ui.ChartView;

import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.proton.carepatchtemp.constant.Config;
import com.proton.carepatchtemp.constant.Extras;
import com.proton.carepatchtemp.utils.FormatUtils;
import com.proton.carepatchtemp.utils.SpUtils;

import java.text.DecimalFormat;

public class MyAxisValueFormatter implements IAxisValueFormatter {

    private DecimalFormat mFormat;

    public MyAxisValueFormatter() {
        mFormat = new DecimalFormat("###,###,###,##0");
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        if (SpUtils.getInt(Extras.TEMP_UNIT, Config.TEMP_UNIT_DEFAULT) == Config.TEMP_UNIT_F) {
            return mFormat.format(FormatUtils.float2double(value)) + "℉";
        } else {
            return mFormat.format(FormatUtils.float2double(value)) + "℃";
        }
    }
}
